package designPattern.Singleton;

/*饿汉式
类加载到内存后，实例化一个单例，JVM保证线程安全
缺点：类装载时就完成实例化*/
public class Singleton01 {
    private static final Singleton01 INSTANCE = new Singleton01();

    private Singleton01(){}

    public static Singleton01 getInstance() {return INSTANCE;}

    public void m() {
        System.out.println("m");
    }

    public static void main(String[] args) {
        Singleton01 s1 = Singleton01.getInstance();
        Singleton01 s2 = Singleton01.getInstance();
        System.out.println(s1==s2);
    }

}
